class Loader:
	"""util class for dynamically loading package/class"""

	def loadPackage(self, name):
		"""dynamically import a package"""
		mod = __import__(name)
		components = name.split(".")
		for comp in components[1:]:
			mod = getattr(mod, comp)
		return mod

	def loadObject(self, name):
		"""dynamically import a class"""
		components = name.split(".")
		pkgs = components[1:-1]
		pkg = components[0]
		for p in pkgs:
			pkg += "." + p
		clazz = components[-1]
		mod = self.loadPackage(pkg)
		obj = getattr(mod, clazz)
		return obj
